package com.yanzhu.service.mapper;

import com.yanzhu.service.model.Message;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: 方炎柱
 * @Description:
 * @Date: Created in 10:48 2018/2/2
 * @Modified:
 */
@Mapper
public interface MessageMapper {

    @Insert("insert into message(uid, vid, oid, name, content, type, avatar, image_path, message_time) values(#{uid}, #{vid}, #{oid}, #{name}, #{content}, #{type}, #{avatar}, #{image_path}, #{message_time})")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = long.class)
    int insert(Message message);

    @Select("select * from message" +
            " where uid = #{uid}" +
            " order by message_time desc" +
            " limit #{page}, ${size}")
    List<Message> queryMessageList(@Param("uid") long uid, @Param("page") int page, @Param("size") int size);
}
